/**
 * 文件名：RentType.java
 *
 * 创建人：Fyh - 1009173473@qq.com
 *
 * 创建时间：2019年8月8日 下午3:32:10
 *
 * 版权所有：南京植百汇智能科技服务有限公司
 */
package com.z100h.supplychain.core;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * 
 * [供应链-erp视图中的生产状态]
 * 生产状态 0.未完成 1.已完成，待质检 2.质检不合格，重新生产 3.质检合格，生产完成
 *
 * @author Elvin Zhao - 279152260@qq.com
 * @version 1.0 Created on 2019年9月9日 下午2:49:39
 */
public enum ProductionState {

	UNPRODUCTIONCOMPLETION("生产未完成", "0"), PRODUCTIONCOMPLETION("生产完成", "1"), QCFAILED("质检未通过", "2"), QCPASS("质检通过",
			"3"), OUTFINISH("已经出库", "4");

	private String name;

	private String type;

	private ProductionState(String name, String type) {
		this.name = name;
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public static ProductionState get(String rentType) {
		switch (rentType) {
			case "1":
				return PRODUCTIONCOMPLETION;
			case "2":
				return QCFAILED;
			case "3":
				return QCPASS;
			case "4":
				return OUTFINISH;
			default:
				return UNPRODUCTIONCOMPLETION;
		}
	}

	public static JSONArray getProductionState() {
		JSONArray array = new JSONArray();

		JSONObject obj0 = new JSONObject();
		obj0.put("key", PRODUCTIONCOMPLETION.type);
		obj0.put("value", PRODUCTIONCOMPLETION.name);

		JSONObject obj1 = new JSONObject();
		obj1.put("key", QCFAILED.type);
		obj1.put("value", QCFAILED.name);

		JSONObject obj2 = new JSONObject();
		obj2.put("key", QCPASS.type);
		obj2.put("value", QCPASS.name);

		JSONObject obj3 = new JSONObject();
		obj3.put("key", OUTFINISH.type);
		obj3.put("value", OUTFINISH.name);

		JSONObject obj4 = new JSONObject();
		obj4.put("key", UNPRODUCTIONCOMPLETION.type);
		obj4.put("value", UNPRODUCTIONCOMPLETION.name);

		array.add(obj0);
		array.add(obj1);
		array.add(obj2);
		array.add(obj3);
		array.add(obj4);
		return array;
	}
}
